package keyfun.utils 
{
	/**
	 * Sorting
	 * @author Key Hui
	 */
	public class SortUtil
	{
		/**
		 * Shuffle function for Array.sort, not accurate since Math.random is not uniform
		 * @param	a
		 * @param	b
		 * @return
		 */
		public static function shuffle(a:Object, b:Object):int 
		{
			//var num:int = Math.round(Math.random() * 2) - 1;
			var num:int = Math.round(Math.random());
			return num;
		}
		
		public static function shuffleArray(a:Array):Array
		{
			var i:int = a.length;
			var j:int;
			var temp:Object;
			if (i == 0) return a;
			while (--i) 
			{
				j = Math.floor( Math.random() * ( i + 1 ) );
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
			return a; 
		}
		
	}

}